/*
 * The MIT License (MIT)
 *
 * Copyright (c) 2014-2015 abel533@gmail.com
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

package com.github.abel533.echarts.samples.pie;

import java.util.ArrayList;
import java.util.List;

import org.junit.Test;

import com.github.abel533.echarts.Legend;
import com.github.abel533.echarts.Title;
import com.github.abel533.echarts.Toolbox;
import com.github.abel533.echarts.Tooltip;
import com.github.abel533.echarts.code.Orient;
import com.github.abel533.echarts.code.SeriesType;
import com.github.abel533.echarts.code.Tool;
import com.github.abel533.echarts.code.Trigger;
import com.github.abel533.echarts.data.Data;
import com.github.abel533.echarts.series.Pie;
import com.github.abel533.echarts.series.Series;
import com.github.abel533.echarts.util.EnhancedOption;

/**
 * 简单饼图
 *
 * @author liuzh
 * @param <T>
 */
public class PieTest8{

    @Test
    public void test() {
        //地址：http://echarts.baidu.com/doc/example/pie7.html
        EnhancedOption option = new EnhancedOption();
        Title title = new Title();
        title.text("某站点用户访问来源");
        title.subtext("纯属虚构");
        title.x("center");
		option.setTitle(title);
		Tooltip tooltip = new Tooltip();
		tooltip.trigger(Trigger.item);
		tooltip.formatter("{a} <br/>{b} : {c} ({d}%)");
		option.setTooltip(tooltip);
        Legend legend = new Legend();
        legend.orient(Orient.vertical);
        legend.x("left");
        List<String> list1=new ArrayList<String>();
        list1.add("直接访问");
        list1.add("邮件营销");
        list1.add("联盟广告");
        list1.add("视频广告");
        list1.add("搜索引擎");
        legend.data(list1);
		option.setLegend(legend);
		Toolbox toolbox = new Toolbox();
		toolbox.show(true);
		toolbox.feature(Tool.mark, Tool.dataView, Tool.restore, Tool.saveAsImage);
		option.setToolbox(toolbox);
		option.setCalculable(true);
		List<Series> values = new ArrayList<Series>();
		Pie pie=new Pie();
		pie.name("访问来源");
		pie.type(SeriesType.pie);
		List<Data> lDatas=new ArrayList<Data>();
		lDatas.add(new Data("直接访问", 335));
		lDatas.add(new Data("联盟广告", 215));
		lDatas.add(new Data("视频广告", 635));
		lDatas.add(new Data("搜索引擎", 335));
		lDatas.add(new Data("邮件营销", 335));
		pie.setData(lDatas);
//		pie.data(new Data("直接访问", 335),new Data("联盟广告", 335),new Data("视频广告", 335),new Data("搜索引擎", 335));
		values.add(pie);
		option.series(values);
        option.exportToHtml("pie8.html");
        option.view();
    }

   
}
